package com.imooc.framework.compare;

import javax.validation.constraints.NotBlank;
import java.lang.reflect.Field;

public class ObjectCompare {

    public static void main(String[] args) throws IllegalAccessException {
        A B = new A();
        B.setName("小张");
        B.setAge(19);

        A C = new A();
        C.setName("小李");
        C.setAge(19);

        Field[] fields = A.class.getDeclaredFields();
//        for (Field field : fields) {
//            field.setAccessible(true);
//            Object valueOfB = field.get(B);
//            Object valueOfC = field.get(C);
//            if (valueOfB.equals(valueOfC)) {
//                System.out.println("属性" + field.getName() + "的值在B和C中相同，值为：" + valueOfB);
//            } else {
//                System.out.println("属性" + field.getName() + "的值在B和C中不同，值分别为：B=" + valueOfB + "，C=" + valueOfC);
//            }
//        }

        for (Field field : fields) {
//            if (field.isAnnotationPresent(NotBlank.class)) {
                System.out.println( field.getName());
//            }
        }


    }
}
